<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$_SESSION['uid']=$_SESSION['uid']?:0;
if($_RQ['op']=='main'){
	//返回链接
	$isfollow=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'follow');	
	if(!$isfollow && $_RQ['fromcreate'] && !$shopset['noshowqrcode']){
		$return['showwechatcode']=1;
	}
	$return['type']='log';
	$return['params']=array('status'=>100);
	$return['list']=array();
	set_html('title','发票列表');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if(isset($_RQ['status']) && $_RQ['status'] !=100){
		$params['status']=intval($_RQ['status']);
		$return['status']=$return['params']['status']=$_RQ['status'];
	}else{
		$return['status']=100;
	}
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=intval($_RQ['ordersn']);
	}
	if(!empty($_RQ['expresssn'])){
		$params['expresssn']=$_RQ['expresssn'];
		$return['params']['expresssn']=$params['expresssn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_invoice_list',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	foreach($list as &$item){
		$item['statustitle']=$this->status[$item['status']];
		$item['address']=json_decode($item['address'],true);
        $item['createtime']=date('Y-m-d',$item['createtime']);
        $item['images']=json_decode($item['images'],true);
        foreach($item['images'] as &$img){
            $img=tomedia($img);
        }
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='cancel'){
	$post=get_postdata();
	$id=intval($post['id']);
	$this->model('model')->jilog_cancel($id);
	exi('取消成功！');	
}
?>